#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include"header.h"


void play()
{
    SDL_Surface *ecran1, *image1;
    int done=1;
    SDL_Event event;
    SDL_Rect  desti;
    int n=20;

    atexit(SDL_Quit);
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        printf( "Echec d'initialisation de SDL.\n");

    }
    else
    {
        printf("SDL est initialisé avec succès.\n");
    };

    //SDL_WM_SetIcon(IMG_Load("icone.png"), NULL);

    ecran1 = SDL_SetVideoMode(0, 0, 0, SDL_ANYFORMAT|SDL_FULLSCREEN);
    if ( ecran1 == NULL )
    {
        printf("Echec de creation de la fenetre\n");
    }

    else
    {
        image1 = SDL_LoadBMP("data/img/commandejeu.bmp");
    }
    if ( image1 == NULL )
    {
        printf("Echec de chargement du fichier image.bmp");

    }
    else
    {
        SDL_BlitSurface(image1, NULL, ecran1, NULL);
        SDL_UpdateRect(ecran1, 0, 0, 0, 0);

    }

//coordonner du bouton jouer

    desti.x = 20;
    desti.y = 494.75;
    desti.w = 144;
    desti.h = 77.21;

    SDL_BlitSurface(image1, NULL, ecran1, NULL);
    SDL_UpdateRect(ecran1, 0, 0, 0, 0);

    while(done)
    {
        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
            case SDL_QUIT:
                done = 0;
                break;
                {
                case SDL_MOUSEBUTTONUP:
                    if (event.button.button == SDL_BUTTON_LEFT && desti.x < event.button.x && event.button.x < desti.x + 144 &&
                            desti.y < event.button.y && event.button.y < desti.y + 77.21)
                        gameplay(n);

                    break;
                }

            case SDL_KEYDOWN:
            {

                if (event.key.keysym.sym == SDLK_ESCAPE)
                    done = 0;
                SDL_Quit();
                break;
            }
            }
        }
    }
}










